import instance from '../utils/request'
// 获取新闻文章详情
export function getDetailApi (id) {
  return instance({
    url: `/v1_0/articles/${id}`,
    needToken: true
  })
}

// 关注用户
export function guanZhu (target) {
  return instance({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: target,
    needToken: true
  })
}

// 取消关注
export function quGuan (target) {
  return instance({
    url: `/v1_0/user/followings/${target}`,
    method: 'DELETE',
    needToken: true
  })
}

// 点赞文章
export function dianZanWenZhang (target) {
  return instance({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: target,
    needToken: true
  })
}

// 取消对文章点赞
export function quXiaoZan (target) {
  return instance({
    url: `/v1_0/article/likings/${target}`,
    method: 'DELETE',
    needToken: true
  })
}

// 对文章不喜欢
export function buXuHuan (target) {
  return instance({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: target,
    needToken: true
  })
}

// 取消对文章不喜欢
export function quXiaoBuXiHuan (target) {
  return instance({
    url: `/v1_0/article/dislikes/${target}`,
    method: 'DELETE',
    needToken: true
  })
}

// 获取文章评论||评论的回复
export function getPingLun ({ type, source, limit }) {
  return instance({
    url: '/v1_0/comments',
    method: 'GET',
    params: {
      type: type,
      source: source,
      limit: limit
    }
  })
}

// 添加文章评论
export function setPingLun ({ target, content, id }) {
  return instance({
    url: '/v1_0/comments',
    method: 'POST',
    data: {
      target: target,
      content: content,
      art_id: id
    },
    needToken: true
  })
}

// 对评论或评论回复点赞
export function getZanpl (target) {
  return instance({
    url: '/v1_0/comment/likings',
    method: 'POST',
    data: target,
    needToken: true
  })
}

// 取消对评论或评论回复点赞
export function clearDianZan (target) {
  return instance({
    url: `/v1_0/comment/likings/${target}`,
    method: 'DELETE',
    needToken: true
  })
}
